/**   
 * @Title: SportteryFootballRecommendAgainstInfoCommunicater.java 
 * @Package com.esun.rabbit2.communicaters.sportteryfootball 
 * @Description: (推荐赛事对阵信息) 
 * @author: City Jiangsy@500wan.com   
 * @date: 2011-9-5 下午02:39:00  
 * Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.sportteryfootball;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Key;
import com.esun.model.sportteryfootball.SportteryFootballAgainstInfo;
import com.esun.network.ServerCommunicater;

/**
 * @ClassName: SportteryFootballRecommendAgainstInfoCommunicater
 * @Description: (推荐赛事对阵信息)
 * @author: City Jiangsy@500wan.com
 * @date: 2011-9-7 上午10:46:45
 * 
 */
public class SportteryFootballRecommendAgainstInfoCommunicater extends ServerCommunicater {
	private String msgServer; // 服务器信息
	private boolean isSucceed = false;

	public String getMsgServer() {
		return msgServer;
	}

	public void setMsgServer(String msgServer) {
		this.msgServer = msgServer;
	}

	public boolean isGetInfoSucceed(int type) throws ClientProtocolException, IOException, ParserConfigurationException, SAXException {
		// this.type = type;

		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(mapItem(BussinessCode.PASER_MID, BussinessCode.MID_SPORTTERFOOTBALL_AGAINSTINFO_RECOMMEND));
		list.add(mapItem(Key.KEY_TYPE, Integer.toString(type)));
		// 写入服务器返回信息
		super.getServerResponse(list, true);
		setMsgServer(super.getErrorMSG());
		if (super.getState() == 100) {
			isSucceed = true;
		} else {
			isSucceed = false;
		}
		return isSucceed;
	}

	public ArrayList<SportteryFootballAgainstInfo> getAgainstInfoList() {

		ArrayList<SportteryFootballAgainstInfo> listSportteryFootballAgainstInfos = new ArrayList<SportteryFootballAgainstInfo>();

		for (int i = 0; i < super.getListResult().size(); i++) {
			SportteryFootballAgainstInfo sportteryFootballAgainstInfo = new SportteryFootballAgainstInfo();
			;// varchar(100) 投注序号
			sportteryFootballAgainstInfo.setMatchNum(super.getListResult().get(i).get(Key.KEY_MATCHNUM));
			// date 比赛归属日
			sportteryFootballAgainstInfo.setMatchNumDate(super.getListResult().get(i).get(Key.KEY_MATCHNUMDATE));
			// varchar(100) 星期几
			sportteryFootballAgainstInfo.setDayOfWeek(super.getListResult().get(i).get(Key.KEY_DAYOFWEEK));
			// int(10) 比赛id
			sportteryFootballAgainstInfo.setId(super.getListResult().get(i).get(Key.KEY_ID));
			// varchar(200) 联赛简称
			sportteryFootballAgainstInfo.setSimpleLeague(super.getListResult().get(i).get(Key.KEY_SIMPLELEAGUE));
			// varchar(200) 主队名称
			sportteryFootballAgainstInfo.setHomeSxName(super.getListResult().get(i).get(Key.KEY_HOMESXNAME));
			// varchar(200) 客队名称
			sportteryFootballAgainstInfo.setAwaySxName(super.getListResult().get(i).get(Key.KEY_AWAYSXNAME));
			// date 投注截止时间
			sportteryFootballAgainstInfo.setPtggEndTime(super.getListResult().get(i).get(Key.KEY_PTGGENDTIME));
			// 竞彩发起用,对阵id
			sportteryFootballAgainstInfo.setxId(super.getListResult().get(i).get(Key.KEY_XID));
			// 竞彩发起用,对阵编号名称
			sportteryFootballAgainstInfo.setProcessName(super.getListResult().get(i).get(Key.KEY_PROCESSNAME));
			// float(10) 主队赔率 Type 为1、2时赔率
			sportteryFootballAgainstInfo.setWin(super.getListResult().get(i).get(Key.KEY_WIN));
			// float(10) 客队赔率 Type 为1、2时赔率
			sportteryFootballAgainstInfo.setLost(super.getListResult().get(i).get(Key.KEY_LOST));
			// float(10) 平局赔率 Type 为1、2时赔率
			sportteryFootballAgainstInfo.setDraw(super.getListResult().get(i).get(Key.KEY_DRAW));
			sportteryFootballAgainstInfo.setRangqiu(super.getListResult().get(i).get(Key.KEY_RANGQIU));

			listSportteryFootballAgainstInfos.add(sportteryFootballAgainstInfo);
		}
		return listSportteryFootballAgainstInfos;
	}

	/**
	 * @Title: mapItem
	 * @Description: (工具类,用于构建AraayList单条内容)
	 * @param @param name 参数名
	 * @param @param value 参数值
	 * @param @return map
	 * @return HashMap<String,String> 返回类型
	 * @throws
	 */
	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}
}
